package com.hopu.v1.controller.admin.exam;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopu.v1.pojo.common.Delete;
import com.hopu.v1.pojo.common.R;
import com.hopu.v1.pojo.common.Save;
import com.hopu.v1.pojo.common.Update;
import com.hopu.v1.pojo.exam.ExamQuestions;
import com.hopu.v1.service.admin.exam.ExamQuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ExamQuestionsController
 * Description:
 *
 * @Author lh
 * @Create 2024/9/25 11:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/examQuestions")
public class ExamQuestionsController {
    @Autowired
    private ExamQuestionsService examQuestionsService;

    /**
     * 新增
     * @param examQuestions
     * @return
     */
    @PostMapping("/add")
    public R add(@Validated(Save.class) @RequestBody ExamQuestions examQuestions) {
        System.out.println(examQuestions);
        examQuestionsService.add(examQuestions);
        return R.ok("添加成功");
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @PostMapping("/del")
    public R del(@Validated(Delete.class) Integer id) {
        System.out.println(id);
        examQuestionsService.del(id);
        return R.ok("操作成功");
    }

    /**
     * 修改
     * @param examQuestions
     * @return
     */
    @PostMapping("/update")
    public R update(@Validated(Update.class) @RequestBody ExamQuestions examQuestions) {
        System.out.println(examQuestions);
        examQuestionsService.update(examQuestions);
        return R.ok("操作成功");
    }

    @GetMapping("/selectList")
    public R selectList(Page<ExamQuestions> page, ExamQuestions examQuestions, String endTime) {
        return R.ok(examQuestionsService.selectList(page, examQuestions,endTime));
    }
}
